<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html">

    <ui:define name="content">
        <p:calendar id="cal"  value="#{channelsearch.date}" pattern="dd MMMM yyyy" >   
            <f:ajax event="dateSelect" execute="cal" render="bSessionSearch" />
        </p:calendar>
        <p:dataTable id="bSessionSearch" value="#{channelsearch.billSessions}" var='bs'
                     filteredValue="#{channelsearch.filteredbillSessions}">


            <p:column headerText="Booking Id" filterBy="#{bs.bill.bookingId}" filterMatchMode="contains">
                <h:commandLink action="channel_booking"> #{bs.bill.bookingId}
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
            </p:column>
            <p:column headerText="Sepeciality" filterBy="#{bs.serviceSession.staff.speciality.name}" filterMatchMode="contains">
                <h:commandLink action="channel_booking">#{bs.serviceSession.staff.speciality.name}
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
            </p:column>
            <p:column headerText="Consultant" filterBy="#{bs.serviceSession.staff.person.nameWithTitle}" filterMatchMode="contains">

                <h:commandLink action="channel_booking">  #{bs.serviceSession.staff.person.nameWithTitle}
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
            </p:column>
            <p:column headerText="Session Name" filterBy="#{bs.serviceSession.name}" filterMatchMode="contains">
                <h:commandLink action="channel_booking">  #{bs.serviceSession.name}
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
            </p:column>
            <p:column headerText="No" filterBy="#{bs.serialNo}" filterMatchMode="contains">
                <h:commandLink action="channel_booking"> #{bs.serialNo}
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
            </p:column>
            <p:column headerText="Patient Name" filterBy="#{bs.bill.patient.person.nameWithTitle}" filterMatchMode="contains">
                <h:commandLink action="channel_booking"> #{bs.bill.patient.person.nameWithTitle}
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
            </p:column>
            <p:column headerText="Paid or Not" filterBy="#{bs.bill.billType}" filterMatchMode="contains">
                <h:commandLink action="channel_booking"> <p:outputLabel rendered="#{bs.bill.billType eq 'ChannelCredit'}" value="Credit" style="color: red;"/>
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
                <h:commandLink action="channel_booking"> <p:outputLabel rendered="#{bs.bill.billType eq 'ChannelPaid'}" value="Paid"/>
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
            </p:column>
            <p:column headerText="C/R" filterBy="#{bs.bill.billClass}" filterMatchMode="contains">
                <h:commandLink action="channel_booking">  <p:outputLabel value="Cancelled" rendered="#{bs.bill.cancelled==true}"/>
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
                <h:commandLink action="channel_booking">  <p:outputLabel value="Refunded" rendered="#{bs.bill.refunded==true}"/>
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
            </p:column>   
            <p:column headerText="Agent" filterBy="#{bs.bill.fromInstitution.institutionCode}" filterMatchMode="contains">
                <h:commandLink action="channel_booking"> <p:outputLabel value="#{bs.bill.fromInstitution.institutionCode}"/>      
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
            </p:column> 
            <p:column headerText="Agent Ref No" filterBy="#{bs.billItem.agentRefNo}" filterMatchMode="contains">
                <h:commandLink action="channel_booking"><p:outputLabel value="#{bs.billItem.agentRefNo}"/>     
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
            </p:column> 
            <p:column headerText="P/A" filterBy="#{bs.absent}" filterMatchMode="contains">                                      
                <h:commandLink action="channel_booking"> <p:outputLabel value="Absent"  rendered="#{bs.absent}"/>  
                    <f:setPropertyActionListener target="#{bookingController.speciality}" value="#{bs.serviceSession.staff.speciality}"/>
                    <f:setPropertyActionListener target="#{bookingController.staff}" value="#{bs.serviceSession.staff}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedServiceSession}" value="#{bs.serviceSession}"/>
                    <f:setPropertyActionListener target="#{bookingController.selectedBillSession}" value="#{bs}"/>
                </h:commandLink>
            </p:column> 
        </p:dataTable> 
    </ui:define>


</ui:composition>
